package genetic.treenodes;

import genetic.Arity;
import genetic.DataSet;
import genetic.GPTreeNode;

public class Addition extends GPTreeNode implements Cloneable {

	@Override
	public Arity getArity() {
		return Arity.one_to_n;
	}
	
	public Addition clone() {
		return (Addition)super.clone();
	}

	/* (non-Javadoc)
	 * @see javax.swing.tree.TreeNode#getAllowsChildren()
	 */
	@Override
	public boolean getAllowsChildren() {
		return true;
	}

	/* (non-Javadoc)
	 * @see javax.swing.tree.TreeNode#isLeaf()
	 */
	@Override
	public boolean isLeaf() {
		return false;
	}

	@Override
	public double getValue(DataSet ds) {
		double sum = 0;
		
		for (int i=0; i<children.size(); i++)
			sum += children.get(i).getValue(ds);
		
		return sum;
	}
	
}
